package com.motorhome.api.dao.impl;

import com.motorhome.api.dao.CarDao;
import com.motorhome.api.domain.Car;
import com.motorhome.base.dao.Pager;
import com.motorhome.base.dao.impl.BaseDaoImpl;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: John
 */
@Repository
public class CarDaoImpl extends BaseDaoImpl implements CarDao {

    @Override
    public Pager<Car> getCarList(int page, int pageSize) {
        return queryForPageByPageNo("select id,name,description,pic_url,view_url,insurance,car_num,device_id,device_number,device_name,flag " +
                        "from m_car where status = 0",
                new Object[]{}, new BeanPropertyRowMapper<>(Car.class), page, pageSize);
    }

    @Override
    public List<Car> getAllCarList() {
        return query("select id,name,description,pic_url,view_url,insurance,car_num,device_id,device_number,device_name,flag " +
                "from m_car where status = 0", new BeanPropertyRowMapper<Car>(Car.class));
    }

}
